<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>文章分类</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
	 <script type="text/javascript">
		 $(function() {
			 mallArticleCategoryModule.init();
		 });

		 var mallArticleCategoryModule = (function(){
			 //初始化文章分类树
			var initArticleCategoryTree = function(){
				$('#parentcategoryid').combotree({
					url : 'mallArticleCategoryController.do?categorytree&selfId=${mallArticleCategoryPage.id}',
					panelHeight: 200,
					width: 157,
					onClick: function(node){
						$("#parentcategoryid").val(node.id);
					}
				});
				if($('#article_cate_select').val()=='1'){
					$('#parent_cate_tr').show();
				}else{
					$('#parent_cate_tr').hide();
				}
			}
			// 分类级别改变事件
			var categoryChange = function(){
				$('#article_cate_select').change(function(){
					if($(this).val()=='1'){//子级分类
						$('#parent_cate_tr').show();
						var t = $('#parentcategoryid').combotree('tree');
						var nodes = t.tree('getRoots');
						if(nodes.length>0){
							$('#parentcategoryid').combotree('setValue', nodes[0].id);
							$("#parentcategoryid").val(nodes[0].id);
						}
					}else{//顶级分类
						$('#parent_cate_tr').hide();
						var t = $('#parentcategoryid').combotree('tree');
						var node = t.tree('getSelected');
						if(node){
							$('#parentcategoryid').combotree('setValue', null);
						}
						$("#parentcategoryid").val(null);
						$('#pfun').hide();
					}
				});
			}
			var module = {
				init : function(){
					initArticleCategoryTree();
					categoryChange();
				}
			}
			 return module;
		 })();
	 </script>
 </head>
 <body style="overflow-y: hidden" scroll="no">
  <t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="mallArticleCategoryController.do?save">
			<input id="id" name="id" type="hidden" value="${mallArticleCategoryPage.id }">
			<table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
				<tr>
					<td align="right">
						<label class="Validform_label">
							分类名称:
						</label>
					</td>
					<td class="value">
						<input class="inputxt" id="categoryname" name="categoryname" 
							   value="${mallArticleCategoryPage.categoryname}" datatype="*">
						<span class="Validform_checktip"></span>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							分类等级:
						</label>
					</td>
					<td class="value">
						<select name="" id="article_cate_select" datatype="*">
							<option value="0" <c:if test="${mallArticleCategoryPage.parentcategoryid == null }">selected="selected"</c:if>>
								顶级分类
							</option>
							<option value="1" <c:if test="${mallArticleCategoryPage.parentcategoryid != null}"> selected="selected"</c:if>>
								子级分类
							</option>
						</select>
					</td>
				</tr>
				<tr id="parent_cate_tr">
					<td align="right">
						<label class="Validform_label">
							上级分类:
						</label>
					</td>
					<td class="value">
						<input class="inputxt" id="parentcategoryid" name="parentcategoryid" 
							   value="${mallArticleCategoryPage.parentcategoryid}" >
						<span class="Validform_checktip"></span>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							分类类型:
						</label>
					</td>
					<td class="value">
						<select id="categorytype" name="categorytype"  datatype="*">
							<option value="category_type_footer" <c:if test="${mallArticleCategoryPage.categorytype eq 'category_type_footer'}"> selected="selected"</c:if>>
								页面底部
							</option>
							<option value="category_type_lhbkb" <c:if test="${mallArticleCategoryPage.categorytype eq 'category_type_lhbkb'}">selected="selected"</c:if>>
								拉货宝快报
							</option>
							<option value="category_type_shop" <c:if test="${mallArticleCategoryPage.categorytype eq 'category_type_shop'}">selected="selected"</c:if>>
								店铺中心
							</option>
							<option value="category_type_recharge" <c:if test="${mallArticleCategoryPage.categorytype eq 'category_type_recharge'}">selected="selected"</c:if>>
								充值说明
							</option>
						</select>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							是否允许多篇文章:
						</label>
					</td>
					<td class="value">
						<select id="ismulty" name="ismulty"  datatype="*">
							<option value="1" <c:if test="${mallArticleCategoryPage.ismulty > 0}">selected="selected"</c:if>>
								是
							</option>
							<option value="0" <c:if test="${mallArticleCategoryPage.ismulty eq 0}"> selected="selected"</c:if>>
								否
							</option>
						</select>
					</td>
				</tr>
			</table>
		</t:formvalid>
 </body>